//
//  CollectTableViewCell.m
//  Youhuiju
//
//  Created by liuovyue on 16/7/26.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "CollectTableViewCell.h"
#import "OrderformCollectionViewCell.h"
#import "CollectionCollection.h"
#import "CollectViewController.h"
#import "AssetsTwoController.h"

@interface CollectTableViewCell()<UICollectionViewDelegate, UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionViewcollect;

@property (nonatomic, strong)NSArray *arr;
@property (nonatomic, strong)NSArray *arrImage;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionTop;


@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionLead;

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionWidth;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *collectionHeight;

@end

@implementation CollectTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.collectionViewcollect.delegate = self;
    self.collectionViewcollect.dataSource = self;
    [self.collectionViewcollect registerNib:[UINib nibWithNibName:@"CollectionCollection" bundle:nil] forCellWithReuseIdentifier:@"CollectionCollection"];
    self.collectionViewcollect.scrollEnabled = NO;
    self.arr = @[@"我的收藏",@"客服中心",@"积分商城",@"赚一赚",@"会员中心",@"积分商城",@"客服中心",@"帮助与反馈"];

    self.arrImage = @[@"hear",@"Layer-24",@"about-us",@"zhuan",@"member",@"store",@"call-center",@"assistance"];
    
   
    self.collectionLead.constant =  0*FitW;
    self.collectionTop.constant = 0*FitH;
    
    self.collectionHeight.constant = 150*FitH;
    self.collectionWidth.constant = 375*FitW;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 3;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
   CollectionCollection *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCollection" forIndexPath:indexPath];
//    cell.order.constant = 25*FitH;
//    cell.topConstants.constant = 5*FitH;
//    cell.buttonConstants.constant = 5*FitH;
    cell.imageCollection.image = [UIImage imageNamed:[self.arrImage objectAtIndex:indexPath.row]];
    
    cell.labelCollection.text = [self.arr objectAtIndex:indexPath.row];
    cell.labelCollection.textColor = [UIColor colorWithHexString:@"333333"];
    
    cell.labelCollection.textAlignment = NSTextAlignmentCenter;
    return cell;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(125 * FitW, 125 * FitH);
}

#pragma mark --collection点击事件
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:
        {
            id object = [self nextResponder];
            while (![object isKindOfClass:[UIViewController class]]&&object != nil) {
        
                object = [object nextResponder];
                
            }
            
            UIViewController *vc = (UIViewController *)object;
            
            CollectViewController *collect = [[CollectViewController alloc]init];
            vc.tabBarController.tabBar.hidden = YES;
            [vc.navigationController pushViewController:collect animated:YES];
            
            
            
            
        }
            break;
        case 1:{
            
            AssetsTwoController *assets = [[AssetsTwoController alloc]initWithNibName:@"AssetsTwoController" bundle:nil];
            assets.labelTitle = [[UILabel alloc]init];
            assets.labelTitle.text = @"客服中心";
            id object = [self nextResponder];
            while (![object isKindOfClass:[UIViewController class]]&&object != nil) {
                object = [object nextResponder];
            }
            UIViewController *vc = (UIViewController *)object;
            [vc.navigationController pushViewController:assets animated:YES];
            vc.tabBarController.tabBar.hidden = YES;
            
            
        }
            break;
            case 2:
        {
          
            AssetsTwoController *assets = [[AssetsTwoController alloc]initWithNibName:@"AssetsTwoController" bundle:nil];
            assets.labelTitle = [[UILabel alloc]init];
            assets.labelTitle.text = @"积分商城";
            id object = [self nextResponder];
            while (![object isKindOfClass:[UIViewController class]]&&object != nil) {
                object = [object nextResponder];
            }
            UIViewController *vc = (UIViewController *)object;
            vc.tabBarController.tabBar.hidden = YES;
            [vc.navigationController pushViewController:assets animated:YES];
            
            
            
        }
            break;
        default:
            break;
    }
    
    
    
    
    
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
